﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:localUI="clr-namespace:River.Folderize.UI">

  <ControlTemplate x:Key="ImageButtonTemplate" TargetType="{x:Type localUI:ImageButton}">
    <Grid x:Name="Grid">
      <Border 
        x:Name="Background" 
        Background="{TemplateBinding Background}" 
        BorderBrush="{TemplateBinding BorderBrush}" 
        BorderThickness="{TemplateBinding BorderThickness}" />
        <Image x:Name="ButtonImage" 
               Source="{Binding NormalImage, RelativeSource={RelativeSource TemplatedParent}}" 
               Height="{Binding ImageSize, RelativeSource={RelativeSource TemplatedParent}}" 
               Width="{Binding ImageSize, RelativeSource={RelativeSource TemplatedParent}}"
               ToolTip="{TemplateBinding ToolTip}"
               RenderOptions.BitmapScalingMode="NearestNeighbor" />
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsMouseOver" Value="true">
        <Setter TargetName="ButtonImage" Property="Source" Value="{Binding HoverImage, RelativeSource={RelativeSource TemplatedParent}}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="true">
        <Setter TargetName="ButtonImage" Property="Source" Value="{Binding PressedImage, RelativeSource={RelativeSource TemplatedParent}}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="false">
        <Setter TargetName="ButtonImage" Property="Source" Value="{Binding DisabledImage, RelativeSource={RelativeSource TemplatedParent}}" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style TargetType="{x:Type localUI:ImageButton}" BasedOn="{x:Null}">
    <Setter Property="Padding" Value="3" />
    <Setter Property="Margin" Value="5" />
    <Setter Property="ImageSize" Value="16" />
    <Setter Property="BorderThickness" Value="3"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="Template" Value="{StaticResource ImageButtonTemplate}" />
  </Style>

</ResourceDictionary>
